pooling.ts 954 B

123456789101112131415161718192021222324252627282930313233
  1. import { NextApiRequest, NextApiResponse } from 'next'
  2. import apiWrapper from '@/lib/api/apiWrapper'
  3. export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
  4. async function handler(req: NextApiRequest, res: NextApiResponse) {
  5. const { method } = req
  6. switch (method) {
  7. case 'GET':
  8. return handleGetAll(req, res)
  9. case 'PATCH':
  10. return handlePatch(req, res)
  11. default:
  12. res.setHeader('Allow', ['GET', 'PATCH'])
  13. res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
  14. }
  15. }
  16. const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => {
  17. const project: any = {
  18. db_port: 6543,
  19. pool_mode: 'transaction',
  20. pgbouncer_enabled: true,
  21. pgbouncer_status: 'COMING_UP',
  22. }
  23. return res.status(200).json({ project })
  24. }
  25. const handlePatch = async (_req: NextApiRequest, res: NextApiResponse) => {
  26. return res.status(200).json({})
  27. }